/**
 * @(#)Student.java
 *
 * Copyright: Copyright (c) 2003 Carnegie Mellon University
 *
 * This program is the implementation of the original system in the Assignment 2 of "Architectures
 * of Software Systems" class. For the details of each classes, please refer to the provided javadoc
 * documents. You will also find some useful information such as implementation decisions, coding
 * standards, and naming conventions in the README file.
 *
 * History:
 *
 * Date          Author              Change
 * ----------    ----------------    ---------------------------------------------------------------
 * 07/15/2003    Jung Soo Kim        Initial version.
 */


import java.io.Serializable;
import java.util.ArrayList;
import java.util.StringTokenizer;


/**
 * This class represents a record of a student. This class contains a student's personal information
 * and the course numbers the student has completed. This class is constructed from a field-oriented
 * and space-separated string. For the detailed format of such a string refer to 
 * {@link #Student(String)}. This class implements <code>Serializable</code> so that instances of
 * this class can be passed between machines through RMI.
 *
 * @author Jung Soo Kim
 * @version 1.0
 */
public class User implements Serializable {

    /**
     * A string representing this student's ID.
     */
    protected String sUserID;

    /**
     * A string representing this student's last name.
     */
    protected String sUserPasswd;
    /**
     * Constructs a student record by parsing the given string. The argument <code>sInput</code> is
     * field-oriented and space-separated string. The first three required fields are student ID,
     * name, and program affiliation. If this student has completed some courses, the course ID of
     * those courses follow. Here is an example:
     * <p>
     * <code>700001234 Carson Kit MSE 17651 12345 15123</code>
     * <p>
     * Though not necessary, avoid embedding newline characters in the <code>sInput</code> string.
     *
     * @param sInput the string to be parsed representing a student record
     */
    public User(String sID, String sPasswd)
    {
        // Get this student's ID, name, and program.
        this.sUserID  = sID;
        this.sUserPasswd  = sPasswd;
    }
    
    public boolean match(String sUID) {
        return this.sUserID.equals(sUID);
    }
    
    public boolean matchPasswd(String sPasswd) {
        return this.sUserPasswd.equals(sPasswd);
    }
    
    public String getID() {
        return this.sUserID;
    }
    
    public String toString() {
        // Create a string to return using ID, name, and program.
        String sReturn = this.sUserID + " " + this.sUserPasswd;

        return sReturn;
    }
}
